<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/uploadifive/jquery.uploadifive.js"></script>
<style type="text/css">
    body {min-width:600px !important; overflow:scroll !important; overflow-x:hidden !important;}
    .order-item-box {
        width:100%;
        height:auto;
        overflow:hidden;
        padding-bottom:15px;
        margin-bottom:15px;
    }
    .tongrong-box input[type="text"],.tongrong-box select {
        background:none;
    }
    }
    .ico-close {z-index:999;}
</style>
<div class="tongrong-box" style="width:680px;">
    <form class="order-item-box J-ajaxForm" action="<?php echo $this->data['et_rprice']>0 ? "/estimate/save/option/rsave/" : "/estimate/save/option/save/"?>" method="post" autocomplete="off">

        <?php if($this->data['et_status']=='退回'){ ?>
            <table width="100%" cellpadding="0" cellspacing="0" border="1">
                <tr>
                    <td width="90px" height="50">退回备注：</td>
                    <td colspan="3" style="color:#FF0000">
                        <?php echo $this->data["et_fremarks"];?>
                    </td>
                </tr>
            </table>
        <?php } ?>

        <?php if($this->data['et_rprice']>0) { ?>
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td style="text-align: right" width="15%" height="20px">客户姓名：</td>
                    <td width="17%">
                        <?php echo $this->data['et_name'];?>
                    <td style="text-align: right" width="15%">车架号后六位：</td>
                    <td width="17%">
                        <?php echo $this->data['et_code'];?>
                    </td>
                    <td width="15%">上牌注册日期：</td><td width="17%"><?php echo $this->data['et_car_date'];?></td>
                </tr>
                <tr>
                    <td height="20px" style="text-align: right">车辆类型：</td>
                    <td>
                        <?php echo $this->data['et_car_type'];?>
                    </td>
                    <td style="text-align: right">车型：</td>
                    <td colspan="3">
                        <?php echo $this->data['et_car_model'];?>
                    </td>
                </tr>
                <tr>
                        <td height="20px" style="text-align: right">贷款银行：</td>
                        <td colspan="5">
                        <?php echo $this->data['et_bank']; ?>
                            </td>

                </tr>
                <tr>
                    <td style="text-align: right">评估要求：</td>
                    <td colspan="5">
                        <?php echo $this->data['et_remarks'];?>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right">第一次评估价：</td>
                    <td style="color: #FF0000" >
                        <?php echo $this->data['et_price_one'];?>
                    </td>
                    <td style="text-align: right">评估员：</td>
                    <td style="color: #FF0000"><?php echo $this->data['et_fname'];?></td>
                    <td style="text-align: right">评估时间：</td>
                    <td style="color: #FF0000"><?php echo empty($this->data['et_ftime']) ? '' : date('Y-m-d H:i:s', $this->data['et_ftime']);?></td>
                </tr>
            </table>
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td height="40px" width="15%" style="text-align: right">要求重评备注：</td>
                    <td colspan="5">
                        <input size="20" style="width: 500px" name="et_remarks_two" value="<?php echo $this->data['et_remarks_two'];?>" id="et_remarks_two"  />
                    </td>
                </tr>
            </table>
        <?php } else{ ?>
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td width="15%" height="25px">客户名:</td>
                    <td width="17%">
                        <input size="20" style="width: 100px" name="et_name" type="text" id="et_name" value="<?php echo $this->data['et_name'];?>" />
                    <td  width="19%">车架号后六位:</td>
                    <td width="17%">
                        <input size="20" style="width: 100px" name="et_code" type="text" id="et_code" value="<?php echo $this->data['et_code'];?>" />
                    </td>
                    <td width="15%">上牌注册日期：<input type="hidden" name="et_stime" value="<?php echo $this->data['et_stime'] >0 ? $this->data['et_stime'] : time();?>" /></td>
                    <td width="17%">
                    <input size="20" style="width: 100px" name="et_car_date" type="text" onClick="WdatePicker()" id="et_car_date" value="<?php echo $this->data['et_car_date'];?>" />
                </td>
                </tr>
                <tr height="35px">
                    <td style="text-align: right">车型:</td>
                    <td colspan='2'><input type="text" class="J-ot-car-model" value="<?php echo $this->data['et_car_model'];?>" name="et_car_model" id='J-ot-car-model' style="width:193px;" /></td>
                        <td colspan='2'><input type="text" class="J-ot-car-fullmodel" id="J-ot-car-fullmodel" value="<?php echo $this->data['et_car_fullmodel'];?>" name="et_car_fullmodel" style="width:247px;"/></td>
                        <td><span class="J-ot-car-seating"><?php if(!empty($this->data['et_seat_number'])){echo $this->data['et_seat_number'].'座';}?></span>&nbsp;
                        <input type="hidden" class="J-ot-car-seating-value" name="et_seat_number" value="<?php echo $this->data['et_seat_number'];?>" />
                        <span class="J-ot-car-type"><?php echo $this->data['et_car_type'];?></span>
                        <input type="hidden" class="J-ot-car-type-value" name="et_car_type" value="<?php echo $this->data['et_car_type'];?>" />
                        <script type="text/javascript">
                                $(".J-ot-car-fullmodel").blur(function(){
                                    var car_fullmodel = document.getElementById("J-ot-car-fullmodel").value;
                                    $.post('/public/ajax/option/carmsg/',{"car_fullmodel":car_fullmodel},function(data){
                                        var obj = JSON.parse(data);
                                        if(obj['success']){
                                            $(".J-ot-car-type").html(obj['msg']['type']);
                                            $(".J-ot-car-seating").html(obj['msg']['seat_number']+'座');
                                            $(".J-ot-car-type-value").val(obj['msg']['type']);
                                            $(".J-ot-car-seating-value").val(obj['msg']['seat_number']);
                                        }   
                                });
                                });
                     </script>
                </tr>
                <tr>
                    <td height="25px">期望车价(元)：</td>
                    <td>
                        <input size="20" style="width: 100px" name="et_carprice" type="text" id="et_carprice" value="<?php echo $this->data["et_carprice"];?>" />
                    </td>
                    <td style="text-align: right">贷款额(元)：</td>
                    <td>
                        <input size="20" style="width: 100px" type="text" name="et_loan" id="et_loan" value="<?php echo $this->data['et_loan'];?>" />
                    </td>

                    <td style="text-align: right">公司费率%：</td>
                    <td>
                        <input size="20" style="width: 100px" name="et_rate" type="text" id="et_rate" value="<?php echo $this->data["et_rate"];?>" />
                    </td>
                </tr>
                <tr>
                    <td colspan="6">贷款银行：
                            <select name="et_bank" id="et_bank" style="width:320px;">
                                <option value=""><?php echo $this->data["et_bank"];?></option>
                                <?php if(!empty($this->data['bank'])) foreach($this->data['bank'] as $key => $val){?>
                                    <option value="<?php echo $val['bk_id'];?>"><?php echo $val['bk_name'];?></option>
                                <?php } ?>
                            </select>
                        </td>
                   <input type="hidden" name="et_stime" value="<?php echo $this->data['et_stime'] >0 ? $this->data['et_stime'] : time();?>" />
                </tr>
            </table>
            <style type="text/css">
                .uploadifive-button {width:84px;height:84px !important;line-height:normal;margin-top:-84px;background:none !important;}

                .file-upload-completed,.uploadifive-queue-item {position:absolute;width:84px;bottom:0;}

                .uploadifive-queue-item .close {background: url('<?php echo BASE_STYLE;?>/uploadifive/uploadifive-cancel.png') 0 0 no-repeat;display: block;float: right;height: 16px;
                    text-indent: -9999px;width: 16px;}
                .uploadifive-queue-item .progress {height: 3px;margin-top: 5px;width: 100%;}
                .uploadifive-queue-item .progress-bar {background-color: #0072BC;height: 3px;width: 0;}

                .uploadifive-queue-item .filename {display:none;}
                input[type="text"],select {background:none;}
                .order-mianqian-load { padding:15px 10px;}
            </style>

            <fieldset style="border:1px solid #a8a8a8; padding:10px 15px;">

                <dl class="mianqianxinxi-box">
                    <dt>车辆照片(最多16张)</dt>
                    <dd class="mianqianxinxi-pic-list J-box-estimate-car">
                        <?php if(!empty($this->data['attachment']['car'])) foreach($this->data['attachment']['car'] as $k=>$v){?>
                            <div style="position:relative;display:inline-block; float:left;margin-right:10px;">
                                <em class="ico-close J-ico-close"></em>
                                <a href="<?php echo $this->data['attachment']['car_url'][$k];?>" data-lightbox="pic" style="position:relative; display:inline-block; width:80px;height:80px;margin-right:10px;">
                                    <img class="example-image" src="<?php echo $this->data['attachment']['car_thurl'][$k];?>" width="80" height="80" />
                                    <input type="hidden" value="<?php echo $v;?>" name="et_car[]" />
                                </a>
                            </div>
                            <?php
                        }
                        ?>
                    </dd>
                    <dd>
                        <div class="file-upload-box J-file-upload-box fn-left mr10">
                            <div class="file-upload-completed" id="J_estimate_car"></div>
                            <img src="<?php echo BASE_STYLE;?>/images/btn_upload_pic.png" />
                            <input type="file" id="upload_estimate_car" name="upload-pic" size="30" hidefocus="true" multiple='false' accept="image/*"/>
                        </div>

                    </dd>
                </dl>

                <dl class="mianqianxinxi-box">
                    <dt>行驶证/登记证照片</dt>
                    <dd class="mianqianxinxi-pic-list J-box-estimate-plate">
                        <?php if(!empty($this->data['attachment']['plate'])) foreach($this->data['attachment']['plate'] as $k=>$v){?>
                            <div style="position:relative;display:inline-block; float:left;margin-right:10px;">
                                <em class="ico-close J-ico-close"></em>
                                <a href="<?php echo $this->data['attachment']['plate_url'][$k];?>" data-lightbox="pic" style="position:relative; display:inline-block; width:80px;height:80px;margin-right:10px;">
                                    <img class="example-image" src="<?php echo $this->data['attachment']['plate_thurl'][$k];?>" width="80" height="80" />
                                    <input type="hidden" value="<?php echo $v;?>" name="et_plate[]" />
                                </a>
                            </div>
                            <?php
                        }
                        ?>
                    </dd>
                    <dd>
                        <div class="file-upload-box J-file-upload-box fn-left mr10">
                            <div class="file-upload-completed" id="J_estimate_plate"></div>
                            <img src="<?php echo BASE_STYLE;?>/images/btn_upload_pic.png" />
                            <input type="file" id="upload_estimate_plate" name="upload-pic" size="30" hidefocus="true" multiple='false' accept="image/*"/>
                        </div>

                    </dd>
                </dl>

                <dl class="mianqianxinxi-box">
                    <dt>出厂铭牌照片</dt>
                    <dd class="mianqianxinxi-pic-list J-box-estimate-comp">
                        <?php if(!empty($this->data['attachment']['comp'])) foreach($this->data['attachment']['comp'] as $k=>$v){?>
                            <div style="position:relative;display:inline-block; float:left;margin-right:10px;">
                                <em class="ico-close J-ico-close"></em>
                                <a href="<?php echo $this->data['attachment']['comp_url'][$k];?>" data-lightbox="pic" style="position:relative; display:inline-block; width:80px;height:80px;margin-right:10px;">
                                    <img class="example-image" src="<?php echo $this->data['attachment']['comp_thurl'][$k];?>" width="80" height="80" />
                                    <input type="hidden" value="<?php echo $v;?>" name="et_comp[]" />
                                </a>
                            </div>
                            <?php
                        }
                        ?>
                    </dd>
                    <dd>
                        <div class="file-upload-box J-file-upload-box fn-left mr10">
                            <div class="file-upload-completed" id="J_estimate_comp"></div>
                            <img src="<?php echo BASE_STYLE;?>/images/btn_upload_pic.png" />
                            <input type="file" id="upload_estimate_comp" name="upload-pic" size="30" hidefocus="true" multiple='false' accept="image/*"/>
                        </div>

                    </dd>
                </dl>
            </fieldset>
        <?php } ?>





        <div class="order-item-box mt30">
            <input type="hidden" name="option" value="save" />
            <input type="hidden" name="id" value="<?php echo $this->id;?>" />
            <input type="hidden" name="temp_id" value="<?php $temp_id = rand(1000,9999).rand(10000,99999); echo $temp_id;?>"/>
            <input type="hidden" name="et_status" value="<?php echo $this->data['et_status'];?>" />
            <input class="btn-submit-blue fn-left mr15 J-esubmit" type="submit" value="<?php echo $this->data['et_rprice']>0 ? '重评提交' : '提交';?>" />
            <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
        </div>
    </form>
</div>

<script type="application/javascript">
    //表单验证
    function submitChk(){
        <?php if($this->data['et_rprice']>0) { ?>
        if($("#et_remarks_two").val() == ''){
            Ext.Msg.alert('提示','要求重评备注不能为空!');
            return false;
        }
        <?php } else { ?>
        if($("#et_code").val() == ''){
            Ext.Msg.alert('提示','车架号不能为空!');
            return false;
        }

        if($("#et_name").val() == ''){
            Ext.Msg.alert('提示','客户姓名不能为空!');
            return false;
        }
        if($("#et_car_type").val() == ''){
            Ext.Msg.alert('提示','车辆类型不能为空!');
            return false;
        }
        if($("#et_car_model").val() == ''){
            Ext.Msg.alert('提示','车辆型号不能为空!');
            return false;
        }
        if($("#et_car_date").val() == ''){
            Ext.Msg.alert('提示','上牌注册日期不能为空!');
            return false;
        }
        if($("#et_carprice").val() == ''){
            Ext.Msg.alert('提示','希望车价不能为空!');
            return false;
        }
        if($("#et_load").val() == ''){
            Ext.Msg.alert('提示','贷款额不能为空!');
            return false;
        }
        if($("#et_rate").val() == ''){
            Ext.Msg.alert('提示','公司费率不能为空!');
            return false;
        }
        if($("#et_bank").val() == ''){
            Ext.Msg.alert('提示','贷款银行不能为空!');
            return false;
        }
        <?php } ?>
        $(".J-esubmit").prop('disabled',true);

    }

</script>
<script type="text/javascript">
    <?php $timestamp = time();?>
    var names = {'order_cert':'.J-box-order-cert', 'order_assets':'.J-box-order-assets','order_family':'.J-box-order-family','order_sign':'.J-box-order-sign','order_video':'.J-box-order-video', 'order_flowing':'.J-box-order-flowing', 'order_other':'.J-box-order-other','order_contract':'.J-box-order-contract','estimate_car':'.J-box-estimate-car','estimate_plate':'.J-box-estimate-plate','estimate_comp':'.J-box-estimate-comp'};
    function render_upload() {
        var key;
        var limit;
        for (key in names) {
            if(key == 'order_video'){
                var url="/order/upfile/option/video/";
                var fileTypeTxt = 'video/*';
            }else{
                var url="/order/upfile/option/upimage/";
                var fileTypeTxt = 'image/*';
            }
            if(key == 'estimate_car'){
                limit = 16;
            }else if(key == 'estimate_plate'){
                limit = 5;
            }else{
                limit= 1;
            }
            $('#upload_' + key).uploadifive({
                'auto': true,
                'width': 84,
                'buttonText': '',
                'removeTimeout':1,
                'fileObjName':'upload-pic',
                'formData': {
                    'timestamp': '<?php echo $timestamp;?>',
                    'tb':key,
                    'filebox':'upload-pic',
                    'token': '<?php echo md5('unique_salt' . $timestamp);?>',
                    'temp_id' : <?php echo $temp_id;?>
                },
                'number': key,
                'queueClass':names[key],
                'uploadScript': url,
                'removeCompleted' : true,
                'uploadLimit'     : limit,
                'fileType' : fileTypeTxt,
                'onSelect' : function(q, opt){
                    //$('#'+opt.formData.key + opt.number).find('a').remove();
                },
                'onUploadComplete': function (file, data, opt) {
                    var obj = $.parseJSON(data);

                    if (data == 0) {
                        alert('您上传的文件不是允许的图片文件！');
                        return;
                    };

                    if(obj['success']){
                        var html='';
                        html+='<div style="position:relative;display:inline-block; float:left;margin-right:10px;">';
                        html+='	<em class="ico-close J-ico-close"></em>';
                        if(opt['number'] == 'order_video'){
                            html+='<a href="javascript:;" class="J-video-obj" data-url="'+obj['msg']['ai_ftpurl']+''+obj['msg']['ai_path']+'" style="position:relative; display:inline-block; width:80px;height:80px;">';
                        }else{
                            html+='<a href="'+obj['msg']['thumb_path']+'" data-lightbox="pic" style="position:relative; display:inline-block; width:80px;height:80px;">';
                        }


                        switch(opt.number){
                            case 'order_cert':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_cert[]" />';
                                break;
                            case 'order_assets':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_assets[]" />';
                                break;
                            case 'order_family':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_family[]" />';
                                break;
                            case 'order_sign':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_sign[]" />';
                                break;
                            case 'order_flowing':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_flowing[]" />';
                                break;
                            case 'order_other':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_other[]" />';
                                break;
                            case 'order_contract':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="oa_contract[]" />';
                                break;
                            case 'estimate_car':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="et_car[]" />';
                                break;
                            case 'estimate_plate':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="et_plate[]" />';
                                break;
                            case 'estimate_comp':
                                html+='	<img class="example-image" src="'+obj['msg']['thumb_path']+'" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['ai_path']+'" name="et_comp[]" />';
                                break;
                            case 'order_video':
                                html+='	<img class="example-image" src="<?php echo BASE_STYLE;?>/images/member/default_sildeshow.gif" width="80" height="80" />';
                                html+='	<input type="hidden" value="'+obj['msg']['af_path']+'" name="oa_video[]" />';
                                break;
                        }


                        html+='</a>';
                        html+='</div>';


                        $(opt.queueClass).append(html);
                    }else{
                        Ext.Msg.alert('提示',obj['msg']);
                        return false;
                    }

                }
            });
        }
    };

    $(document).ready(function(e) {
        render_upload();
        //删除上传的图片
        $(".order-item-box").on('click','.J-ico-close',function(){
            $(this).closest('div').remove();
        });

        //默认加载
        //getAttachmentList(true);
    });

    $(".J-a-btn-close").on('click',function(){

        var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
        parent.Ext.getCmp(winElement.id).close();

    });
</script>

    <style type="text/css">
        .mianqianxinxi-box {
            height:auto;
            overflow:hidden;
            margin-top:15px;
        }

        .mianqianxinxi-box dt {
            margin-bottom:10px;
        }
        .mianqianxinxi-box dd {
            float:left;
        }

        .mianqianxinxi-pic-list {
            margin-right:10px;
        }

        .mianqianxinxi-pic-list img {
            margin-right:10px;
        }


    </style>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl_ext.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/estimate_info.js?v=<?php echo time();?>"></script>
<?php include $this->Render('footer.php'); ?>
